package com.august.bean;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : Crazy_August
 * @description : 处理信息类
 * @Time: 2022-02-13   17:03
 */
public class Msg {

    // 状态码 200成功  100失败
    private int status;
    //提示信息
    private String msg;
    // 返回给用户的数据
    private Map<String, Object> data = new HashMap<String, Object>();

    public static Msg success() {
        Msg result = new Msg();
        result.setStatus(200);
        result.setMsg("请求成功");
        return result;
    }

    public static Msg failed() {
        Msg result = new Msg();
        result.setStatus(100);
        result.setMsg("请求失败");
        return result;
    }

    public Msg add(String key, Object value) {
        this.getData().put(key, value);
        return this;
    }

    public Msg() {
    }

    public Msg(int status, String msg, Map<String, Object> data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Msg{" +
                "status=" + status +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
